package com.yitongmao.util;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class X5WebView extends WebView {
    //	@SuppressLint("SetJavaScriptEnabled")
    public X5WebView(Context arg0, AttributeSet arg1) {
        super(arg0, arg1);
        initWebViewSettings();
    }
    private void initWebViewSettings() {
        WebSettings settings = getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
        settings.setSupportZoom(true);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);//适应屏幕，内容将自动缩放
        settings.setUseWideViewPort(true);
        settings.setDefaultTextEncodingName("utf-8");
        settings.setAppCacheEnabled(false);// 设置是否开启缓存
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        // 使用localStorage则必须打开
        settings.setDomStorageEnabled(true);
        settings.setGeolocationEnabled(true);
        settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
        settings.setSupportMultipleWindows(true);
        settings.setSavePassword(false);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setAllowFileAccess(true);
        settings.setAllowContentAccess(true);
        settings.setTextSize(WebSettings.TextSize.NORMAL);
        setVerticalScrollbarOverlay(true);
        setFocusableInTouchMode(true);
        setFocusable(true);
        settings.setBlockNetworkImage(false);//同步加载图片
    }
}
